﻿Public Class UploadControl
#Region "Properties"
    Private _Uploads As List(Of UploadItem)
    Public Property Uploads() As List(Of UploadItem)
        Get
            Return _Uploads
        End Get
        Set(value As List(Of UploadItem))
            _Uploads = value
        End Set
    End Property
    Private _AutoUpload As Boolean = True
    Public Property AutoUpload() As Boolean
        Get
            Return _AutoUpload
        End Get
        Set(value As Boolean)
            _AutoUpload = value
        End Set
    End Property
#End Region

    Private Sub CustomButton1_Click(sender As Object, e As EventArgs) Handles CustomButton1.Click
        UploadsPanel.IsActive = False
        Dim OpenFileDialog1 As New OpenFileDialog
        OpenFileDialog1.Filter = "Image Files (*.jpg;*.png;*.gif;*.bmp)|*.jpg;*.png;*.gif;*.bmp"
        OpenFileDialog1.Multiselect = True
        OpenFileDialog1.ShowDialog()
        If OpenFileDialog1.FileName <> Nothing Then
            For i As Integer = 0 To OpenFileDialog1.FileNames.Length - 1
                UploadsPanel.Controls.Add(New UploadItem(New UploadSettings(UploadsPanel.Controls.Count, OpenFileDialog1.FileNames(i), AutoUpload)))
            Next
        End If
        UploadsPanel.IsActive = True
    End Sub
    Public Sub UploadImage(ByVal Filename As String, Optional AutoCopy As Boolean = False, Optional ShowProgress As Boolean = False, Optional AutoUpload As Boolean = False)
        UploadsPanel.Controls.Add(New UploadItem(New UploadSettings(UploadsPanel.Controls.Count, Filename, AutoUpload, AutoCopy, ShowProgress)))
    End Sub
    Private Sub CustomButton2_Click(sender As Object, e As EventArgs) Handles CustomButton2.Click
        For Each UploadItem As UploadItem In UploadsPanel.Controls
            UploadItem.StartUpload()
        Next
    End Sub
End Class
